package com.hfad.todolistapp;


import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;



public class itemDatabaseHelper extends SQLiteOpenHelper{

    private static final String DB_NAME = "Database";
    private static final int DB_VERSION = 1;

    itemDatabaseHelper (Context context){ super(context, DB_NAME, null, DB_VERSION);}

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        updateMyDatabase(sqLiteDatabase, 0, DB_VERSION);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
        updateMyDatabase(sqLiteDatabase, oldVersion, newVersion);
    }

    public static void AddItem(SQLiteDatabase db, String title, String description, String status) {
        ContentValues itemValues = new ContentValues();
        itemValues.put("TITLE", title);
        itemValues.put("DESCRIPTION", description);
        itemValues.put("STATUS", status);
        // Insert a single row into the table
        db.insert("ITEM_LIST", null, itemValues);
    }

    private void updateMyDatabase(SQLiteDatabase db, int oldVersion, int newVersion) {
        if (oldVersion < 1) {
            db.execSQL("CREATE TABLE ITEM_LIST (_id INTEGER PRIMARY KEY AUTOINCREMENT, "
                    + "TITLE TEXT, "
                    + "DESCRIPTION TEXT, "
                    + "STATUS TEXT);");
        }
    }
}
